-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove global structure in LCD HAL Layer #6597
Conversation
os/drivers/lcd/lcd_dev.c
Outdated
|
||
int pid = kernel_thread("LCD Frame flusing", 204, 8192, lcd_flushing_thread, NULL); | ||
itoa((int)lcd_info, parm_buf, 16); | ||
parm[0] = parm_buf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param[0] = itoa((int)lcd_info, parm_buf, 16);
And don't we need to memset parm_buf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why we need to convert it to ascii and to reconvert to integer.
Is it possible to give the address itself without converting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not possible to pass the address without converting it to string because kernel_thread() function accept the parameter of type FAR char *const argv[].
int kernel_thread(FAR const char *name, int priority, int stack_size, main_t entry, FAR char *const argv[])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param[0] = itoa((int)lcd_info, parm_buf, 16);
And don't we need to memset parm_buf?
I don't think it is needed
could you please explain why you think so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave why you modify this in the COMMIT description? I can't get why you did.
os/drivers/lcd/lcd_dev.c
Outdated
char *parm[2]; | ||
char parm_buf[9]; /* for storing 32 bit address */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The param and param_buf are difficult to distinguish and to know what they are. Could you rename them to know what they are in name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The param and param_buf are difficult to distinguish and to know what they are. Could you rename them to know what they are in name?
fixed
os/drivers/lcd/lcd_dev.c
Outdated
|
||
int pid = kernel_thread("LCD Frame flusing", 204, 8192, lcd_flushing_thread, NULL); | ||
itoa((int)lcd_info, parm_buf, 16); | ||
parm[0] = parm_buf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why we need to convert it to ascii and to reconvert to integer.
Is it possible to give the address itself without converting?
3d5064e
to
0229ed0
Compare
@abhinav-s235 Could you check my comment above? I mean why you did below
|
Previously, while creating frame flushing thread we were not passing lcd_info pointer to function lcd_flushing_thread() that's why we declared it globally but now we are passing it as a parameter to the lcd_flushing_thread() function there is no need to globally declare it. |
os/drivers/lcd/lcd_dev.c
Outdated
@@ -423,13 +424,15 @@ int lcddev_register(struct lcd_dev_s *dev) | |||
{ | |||
char devname[16] = { 0, }; | |||
int ret; | |||
char *task_info[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about flushing_thread_args
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abhinav-s235 Could you check my comment above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
flushing_thread_args
?
It has been changed
The point is you want to remove the global variable. Right? Is that to reduce memory usages? |
0229ed0
to
3668df6
Compare
Commit description has been changed. |
os/drivers/lcd/lcd_dev.c
Outdated
} | ||
cleanup: | ||
lcddbg("ERROR: Failed to register driver %s\n", devname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation should be tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
3668df6
to
ba637df
Compare
@abhinav-s235 Is this verified with real device? |
Yes |
os/drivers/lcd/lcd_dev.c
Outdated
|
||
if (!dev) { | ||
return -EINVAL; | ||
} | ||
|
||
/* Allocate a new lcd_dev driver instance */ | ||
lcd_info = (struct lcd_s *)kmm_zalloc(sizeof(struct lcd_s)); | ||
struct lcd_s *lcd_info = (struct lcd_s *)kmm_zalloc(sizeof(struct lcd_s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move Variable declaration on top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
os/drivers/lcd/lcd_dev.c
Outdated
itoa((int)lcd_info, lcd_info_addr, 16); | ||
flushing_thread_args[0] = lcd_info_addr; | ||
flushing_thread_args[1] = NULL; | ||
int pid = kernel_thread("LCD Frame flusing", 204, 8192, lcd_flushing_thread, (FAR char *const *)flushing_thread_args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also, Let's move variable declaration on top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
ba637df
to
f74e644
Compare
#endif | ||
struct lcd_s *lcd_info; | ||
char *flushing_thread_args[2]; | ||
char lcd_info_addr[9]; /* for storing 32 bit address */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the CONFIG_LCD_FLUSH_THREAD
conditional.
If not, when we disable the config, it will be unused variable warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -441,12 +448,19 @@ int lcddev_register(struct lcd_dev_s *dev) | |||
lcd_info->empty = true; | |||
lcd_info->lcd_kbuffer = (uint8_t *)kmm_malloc(CONFIG_LCD_XRES * CONFIG_LCD_YRES * sizeof(uint16_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The members - do_wait, empty and lcd_kbuffer are valid with the config - CONFIG_LCD_FLUSH_THREAD only?
When the config is disable, they are not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these members are only valid when config CONFIG_LCD_FLUSH_THREAD is enabled
struct lcd_s
…de lcddev_register function Replaced the global LCD HAL layer instance with a local declaration within the lcddev_register function to reduce memory usage and passed this instance to LCD_FLUSH_THREAD by converting its address to a string using atoi() function.
f74e644
to
c0638bb
Compare
Replaced the global LCD HAL layer instance with a local declaration within the lcddev_register() function to reduce memory usage and passed this instance to LCD_FLUSH_THREAD by converting its address to a string using atoi() function.